From c25a75369ac365b833af9c1bae2832438e241a49 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 12 Jan 2016 09:47:31 -0800 Subject: [PATCH] Fix tests on nightly --- tests/support/mod.rs | 16 +++++++++++++--- tests/test_cargo_compile.rs | 4 +++- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/support/mod.rs b/tests/support/mod.rs index 007969051..91c9a6888 100644 --- a/tests/support/mod.rs +++ b/tests/support/mod.rs @@ -269,11 +269,11 @@ pub struct Execs { expect_stdin: Option, expect_stderr: Option, expect_exit_code: Option, - expect_stdout_contains: Vec + expect_stdout_contains: Vec, + expect_stderr_contains: Vec, } impl Execs { - pub fn with_stdout(mut self, expected: S) -> Execs { self.expect_stdout = Some(expected.to_string()); self @@ -294,6 +294,11 @@ impl Execs { self } + pub fn with_stderr_contains(mut self, expected: S) -> Execs { + self.expect_stderr_contains.push(expected.to_string()); + self + } + fn match_output(&self, actual: &Output) -> ham::MatchResult { self.match_status(actual) .and(self.match_stdout(actual)) @@ -321,6 +326,10 @@ impl Execs { try!(self.match_std(Some(expect), &actual.stdout, "stdout", &actual.stderr, true)); } + for expect in self.expect_stderr_contains.iter() { + try!(self.match_std(Some(expect), &actual.stderr, "stderr", + &actual.stdout, true)); + } Ok(()) } @@ -475,7 +484,8 @@ pub fn execs() -> Execs { expect_stderr: None, expect_stdin: None, expect_exit_code: None, - expect_stdout_contains: vec![] + expect_stdout_contains: Vec::new(), + expect_stderr_contains: Vec::new(), } } diff --git a/tests/test_cargo_compile.rs b/tests/test_cargo_compile.rs index afdfed8e8..288c44d86 100644 --- a/tests/test_cargo_compile.rs +++ b/tests/test_cargo_compile.rs @@ -223,10 +223,12 @@ test!(cargo_compile_with_invalid_code { assert_that(p.cargo_process("build"), execs() .with_status(101) - .with_stderr("\ + .with_stderr_contains("\ src[..]foo.rs:1:1: 1:8 error: expected item[..]found `invalid` src[..]foo.rs:1 invalid rust code! ^~~~~~~ +") + .with_stderr_contains("\ Could not compile `foo`. To learn more, run the command again with --verbose.\n")); -- 2.30.2